<?php

class publicGearmandConfig {
    
    #config setting.
    const SERVER_CONFIG_PATH_PREFIX = '/data/gearmand_job/conf/';
    const SERVER_ADDRESS_LIST_CONFIG_FILENAME = 'mstat_logsys_server_list.xml';
    const LOGSYS_DATABASE_CONFIG_FILENAME = 'mstat_logsys_database_list.xml';
    const XML_FILE_OF_USER_AGENT_OS = '/data/gearmand_job/conf/mstat_report_tool_os.xml';
    const XML_FILE_OF_USER_AGENT_BROWSER = '/data/gearmand_job/conf/mstat_report_tool_browser.xml';

    //server list config setting
    static public function getSeverAddressList($log_type=null) {
        $file_path = self::SERVER_CONFIG_PATH_PREFIX;
        $file_name = self::SERVER_ADDRESS_LIST_CONFIG_FILENAME;
        $file_real_path = (empty($log_type)) ? $file_path.$file_name : $file_path.$log_type.'/'.$file_name;
        if (file_exists($file_real_path)) {
            return $file_real_path;
        }
        else {
            return null;
        }
    }

    //logsys database config setting.
    static public function getLogsysDatabaseConfig($log_type) {
        $file_path = self::SERVER_CONFIG_PATH_PREFIX;
        $file_name = self::LOGSYS_DATABASE_CONFIG_FILENAME;
        $file_real_path = $file_path.$log_type.'/'.$file_name;
        if (file_exists($file_real_path)) {
            return $file_real_path;
        }
        else {
            return null;
        }
    }


    #log file setting.
    //log file path.
    const LOG_FILE_PATH = '/data/gearmand_job/logs/';

    //log file's prefix.
    const LOG_FILE_PREFIX = 'log_file_prefix_for_';
    
    //define the database name.
    const PROJECT_DEFAULT_DATABASE_NAME = 'mytv_plus_log';

    //type of the log file's prefix.
    static public $log_file_prefix_for_video_access = 'video_access_log_';
    static public $log_file_prefix_for_plan_subscription = 'plan_subscription_log_';
    static public $log_file_prefix_for_sign_in_out = 'sign_in_out_log_';
    static public $log_file_prefix_for_fp_video_access = 'fp_video_access_log_';
    static public $log_file_prefix_for_fp_page_access = 'fp_page_access_log_';

    //set log type info.
    static public $video_access_log_ = 'Mytv Plus Mstat Video Access Log';
    static public $video_access_log_merge_ = 'Mytv Plus Mstat Video Access Log Merge Table';
    //set the middle fix of merge table.
    static public $video_access_merger_midfix = '_merge_';
    
    //for fp video access.
    static public $fp_video_access_ = 'Mytv Plus Mstat Footprint Video Access Log';
    
    //set the table's engine.
    static public $video_access_log_engine = 'MyISAM';
    static public $fp_video_access_engine = 'InnoDB';


    //import log type setting.
    const IMPORT_LOGTYPE_VIDEO_ACCESS = 'video_access';
    const IMPORT_LOGTYPE_SIGN_IN_OUT = 'sign_in_out';
    const IMPORT_LOGTYPE_PLAN_SUBSCRIPTION = 'plan_subscription';
    const IMPORT_LOGTYPE_FP_PAGE_ACCESS = 'fp_page_access';
    const IMPORT_LOGTYPE_FP_VIDEO_ACCESS = 'fp_video_access';
    const IMPORT_LOGTYPE_FP_VIDEO_ACCESS_WS = 'fp_video_access_ws';

    //gearmand support method class name.
    const GEARMAND_SUPPORT_METHODS_LIST = 'GearmandSupportMethodsList';

    //the time of scling setting.
    static public function timeOfScling() {
        return array(
                    '00'=>array('min'=>'00','max'=>'14'),
                    '15'=>array('min'=>'15','max'=>'29'),
                    '30'=>array('min'=>'30','max'=>'44'),
                    '45'=>array('min'=>'45','max'=>'59')
                );
    }

    //get the age group list
    static public function getAgeGroupId($age) {
        $age_group = array('1'=>'<20','2'=>'21~25','3'=>'26~30','4'=>'31~35','5'=>'36~40','6'=>'41~45','7'=>'46~50','8'=>'50+');
        foreach($age_group as $id=>$ages) {
            $tmp_val = explode('~',$ages);
            if ($age < 20) return 1;
            if ($age > 50) return 8;
            if (count($tmp_val)<2) continue;
            if ($age>=$tmp_val[0] && $age<=$tmp_val[1]) {
                return $id;
            }
        }
        return 1;
    }

    //anaylsis of log data time.(unit is minute).
    const ANAYLSIS_OF_LOG_DATA_TIME = 5;
    
    //set the bin gen script path.
    const GEARMAND_GEN_BIN_SCRIPT_PATH = '/opt/gearmand_job/analysis/';

    
}

final class PGC extends publicGearmandConfig{}

?>
